/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rad.Java.MotelPlus.Class;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import rad.Java.Common.Class.DefaultClass;
import rad.Java.Common.Class.IClass;
import rad.Java.Common.DB.GenerateSql;

/**
 *
 * @author rogerio
 */
public class Stay extends DefaultClass implements IClass{
    // <editor-fold defaultstate="collapsed" desc="Declaration of variables">
        private String _apt_id;
        private String _init_date_time;
        private String _end_date_time;
        private String _price;
        private String _sale_price;
        private String _discount;
        private String _increment;
        private String _total;
        private String _employee_id_checkin;
        private String _employee_id_checkout;
        private String _plaque;
        private String _vehicle;
        private String _person_number;
        private String _status;
    // </editor-fold>

    public Stay(){
        _gsql.setTable("stay");
        _sequence = "stay_stay_id_seq";
    }

    // <editor-fold defaultstate="collapsed" desc="Declaration of methods Get and Set">
        public String getAptId() {
            return _apt_id;
        }

        public void setAptId(String _apt_id) {
            this._apt_id = _apt_id;
        }

        public String getDiscount() {
            return _discount;
        }

        public void setDiscount(String _discount) {
            this._discount = _discount;
        }

        public String getEmployeeIdCheckin() {
            return _employee_id_checkin;
        }

        public void setEmployeeIdCheckin(String _employee_id_checkin) {
            this._employee_id_checkin = _employee_id_checkin;
        }

        public String getEmployeeIdCheckout() {
            return _employee_id_checkout;
        }

        public void setEmployeeIdCheckout(String _employee_id_checkout) {
            this._employee_id_checkout = _employee_id_checkout;
        }

        public String getEndDateTime() {
            return _end_date_time;
        }

        public void setEndDateTime(String _end_date_time) {
            this._end_date_time = _end_date_time;
        }

        public String getIncrement() {
            return _increment;
        }

        public void setIncrement(String _increment) {
            this._increment = _increment;
        }

        public String getInitDateTime() {
            return _init_date_time;
        }

        public void setInitDateTime(String _init_date_time) {
            this._init_date_time = _init_date_time;
        }

        public String getPrice() {
            return _price;
        }

        public void setPrice(String _price) {
            this._price = _price;
        }

        public String getSalePrice() {
            return _sale_price;
        }

        public void setSalePrice(String _sale_price) {
            this._sale_price = _sale_price;
        }

        public String getTotal() {
            return _total;
        }

        public void setTotal(String _total) {
            this._total = _total;
        }

        public String getPersonNumber() {
            return _person_number;
        }

        public void setPersonNumber(String _person_number) {
            this._person_number = _person_number;
        }

        public String getPlaque() {
            return _plaque;
        }

        public void setPlaque(String _plaque) {
            this._plaque = _plaque;
        }

        public String getVehicle() {
            return _vehicle;
        }

        public void setVehicle(String _vehicle) {
            this._vehicle = _vehicle;
        }

        public String getStatus()
        {
            return _status;
        }

        public void setStatus(String value)
        {
            this._status = value;
        }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Declaration of functions">
        public void clear(){
            _id                             = "";
            _apt_id                         = "";
            _init_date_time                 = "";
            _end_date_time                  = "";
            _price                          = "";
            _sale_price                     = "";
            _discount                       = "";
            _increment                      = "";
            _total                          = "";
            _employee_id_checkin            = "";
            _employee_id_checkout           = "";
            _person_number                  = "";
            _plaque                         = "";
            _vehicle                        = "";
            _status                         = "";
        }

        @Override
        public void get(ResultSet rs) {
        try {
            _id                             = rs.getString("stay_id");
            _apt_id                         = rs.getString("stay_apt_id");
            _init_date_time                 = rs.getString("stay_init_date_time");
            _end_date_time                  = rs.getString("stay_end_date_time");
            _price                          = rs.getString("stay_price");
            _sale_price                     = rs.getString("stay_sale_price");
            _discount                       = rs.getString("stay_discount");
            _increment                      = rs.getString("stay_increment");
            _total                          = rs.getString("stay_total");
            _employee_id_checkin            = rs.getString("stay_employee_id_checkin");
            _employee_id_checkout           = rs.getString("stay_employee_id_checkout");
            _person_number                  = rs.getString("stay_number_person");
            _plaque                         = rs.getString("stay_plaque");
            _vehicle                        = rs.getString("stay_vehicle");
            _status                         = rs.getString("stay_status");

        } catch (SQLException ex) {
            Logger.getLogger(Stay.class.getName()).log(Level.SEVERE, null, ex);
        }
        }

        @Override
        public void setGsql() {
            _gsql.setValue( _id                        , "stay_id");
            _gsql.setValue( _apt_id                    ,"stay_apt_id");
            _gsql.setValue( _init_date_time            ,"stay_init_date_time");
            _gsql.setValue( _end_date_time             ,"stay_end_date_time");
            _gsql.setValue( _price                     ,"stay_price");
            _gsql.setValue( _sale_price                ,"stay_sale_price");
            _gsql.setValue( _discount                  ,"stay_discount");
            _gsql.setValue( _increment                 ,"stay_increment");
            _gsql.setValue( _total                     ,"stay_total");
            _gsql.setValue( _employee_id_checkin       ,"stay_employee_id_checkin");
            _gsql.setValue( _employee_id_checkout      ,"stay_employee_id_checkout");
            _gsql.setValue( _person_number             ,"stay_number_person");
            _gsql.setValue( _plaque                    ,"stay_plaque");
            _gsql.setValue( _vehicle                   ,"stay_vehicle");
            _gsql.setValue(_status                     , "stay_status");
        }

        public boolean getByAptId() throws SQLException
        {
            _gsql.prepare();
            _gsql.setValue("", "*");
            _gsql.setCommandType(GenerateSql.CommandType.CMD_SELECT);
            _gsql.setConditionalWhere("stay_apt_id = " + this._apt_id);
            _gsql.setConditionalWhere("stay_status = 'O'"); //Status == Open
            if (_gsql.execute(true))
            {
                if (_gsql.next())
                {
                    get(_gsql.getResultSet());
                    return true;
                }
            }
            return false;
        }
    // </editor-fold>
}
